<?php
header("content-type:application/json;charset=utf-8");

include_once "0.1conn.php"; //连接数据库

$userid = $_POST["userid"];
$password = $_POST["password"];
$query = "SELECT * FROM userlist WHERE pwd = '$password' AND id = '$userid'";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result)) {
    $row = mysqli_fetch_assoc($result); //把搜索结果转化为关联数组
    session_start();    //启用session
    $_SESSION['user'] = $row;   //将用户信息写入session
    $arr = array('loginStatus' => '登陆成功');
} else {
    $arr = array('loginStatus' => '用户名或密码错误');
}
echo json_encode($arr);
mysqli_close($conn);
